package com.un.ebs.inventory.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.un.ebs.core.common.KeyValueDto;
import com.un.ebs.inventory.domain.*;
import com.un.ebs.inventory.dto.*;
import com.un.ebs.inventory.enums.InventoryTypeEnum;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author liubo
 * @since 2020-05-23
 */
public interface InventoryNoteService {

    String addByIn(InventoryNoteAddDto req);


    String addByPurchaseIn(String purchaseOrderId, String warehouseId, List<InventoryNoteItemDto> items);

    /**
     * 工序采购，入库和出库自动完成。
     *
     * @param purchaseOrderId
     * @param productionOrderId
     * @param warehouseId
     * @param skuId
     * @param qty
     */
    void addServicePurchaseInAndOut(String purchaseOrderId, String productionOrderId, String warehouseId, String skuId, double qty);

    void addServiceOut(String productionOrderId, String warehouseId, String skuId, double qty);

    /**
     * 生产入库
     *
     * @param productionOrderId
     * @param skuId
     * @param warehouseId
     * @param qty
     * @return
     */
    String addByProductionIn(String productionOrderId, String skuId, String warehouseId, Double qty);

    /**
     * 销售出库单
     *
     * @param req
     */
    String addBySaleOut(InventoryNoteBySaleOutDto req);

    void addBySaleOut(String saleOrderId, String skuId, String warehouseId, Double qty, String outTypeId);

    String addByOut(InventoryNoteAddDto req);

    String addByMove(InventoryNoteByMoveAddDto req);

    String update(InventoryNoteUpdateDto req);

    void delete(String id);

    void submit(String id);

    void submitCancel(String id);

    void submitCancel(String id, boolean rebuildCheck);

    void submitAll();

    void audit(String id);

    void auditCancel(String id);

    void workflowPass(String noteId, String workflowInstanceId);

    void addByBack(String id);

    void addByBack(InventoryNoteBackDto req);

    boolean isCloseAccount(Date dt);

    void updateFinanceCode(String id, String financeCode, String number);

    void updateFinanceCode(int year, int month, String entId, InventoryTypeEnum type, String financeId, String financeCode);

    void updateFinanceCode(int year, int month, InventoryTypeEnum type, String financeId, String financeCode);

    /**
     * 质检不通过
     *
     * @param inventoryNoteItemId
     * @param notPassQty
     */
    void qualityNotPass(String inventoryNoteItemId, Double notPassQty, String checkNoteId);

    InventoryNote queryById(String id);

    InventoryNoteVo queryViewById(String id);

    IPage<InventoryNoteExt> query(String searchText, String relationNoteId, Boolean auditStatus, InventoryTypeEnum type, Integer pageSize, Integer pageIndex);

    IPage<InventoryNoteExt> query(InventoryNoteQueryRequest req);

    IPage<InventoryNoteExt> query(String searchText, InventoryTypeEnum type, String noteTypeId, int pageSize, int pageIndex);

    List<InventoryNoteExt> queryByRelationNoteId(String relationNoteId);

    IPage<InventoryNoteItemExt> queryItem(String searchText, InventoryTypeEnum type, String noteTypeId, int pageSize, int pageIndex);

    IPage<InventoryNoteItemExt> queryItem(InventoryNoteItemQueryRequest req);

    List<InventoryNoteItem> queryItemById(String id);

    IPage<InventoryNoteItemExt> queryItemById(String id, Integer pageSize, Integer pageIndex);

    List<InventoryNoteItemExt> queryItemExtByRelationNoteId(String id);

    InventoryNoteVo queryRebuildNoteByRelation(String id);

    List<InventoryNoteItemExt> queryItemExtByContractCode(String contractCode);

    IPage<InventoryNoteItemExt> queryItemExtByNoteTypeId(String noteTypeId, String skuId, int pageSize, int pageIndex);

    IPage<InventoryNoteItemExt> queryItemExtByNoteType(InventoryTypeEnum type, String skuId, int pageSize, int pageIndex);

    InventoryNoteItemExt queryItemByItemId(String id);

    List<KeyValueDto> queryEnt();

    @Deprecated
    IPage<JxcView> queryJxc(String searchText, Integer pageSize, Integer pageIndex);

    List<InventoryNoteExt> queryNotSendFinanceByType(int year, int month, InventoryTypeEnum... noteType);

    Double queryCostMoney(InventoryTypeEnum type, int year, int month);

    IPage<InventoryNoteItemBySale> querySaleCanInvoice(String entId,String inventoryNoteCode, Integer pageSize, Integer pageIndex);

    IPage<InventoryNoteItemBySale> querySale(String searchText, String entId, String month, Boolean isNotInvoice, Integer pageSize, Integer pageIndex);

    IPage<InventoryNoteExt> queryCheckNote(String code,Integer accountYear,Integer accountMonth,Integer pageSize,Integer pageIndex);

    List<InventoryNoteExt> queryNoteByContractCode(String contractCode);

    int queryNoteCountByContractCode(String contractCode);

}
